import 'package:flutter/material.dart';
import '../widgets/form/DDRadioGroup.dart';

class DDRadioGroupTest extends StatefulWidget {
  @override
  _DDRadioGroupTestState createState() => _DDRadioGroupTestState();
}

class _DDRadioGroupTestState extends State<DDRadioGroupTest> {
  int rvalue = 0;
  void _onChange(value) {
    setState(() {
      rvalue = value;
    });
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text("a"),
        backgroundColor: Colors.green,
      ),
      body: new Center(
        child: new Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            new Radio(
              value: 1,
              groupValue: rvalue,
              onChanged: (int rval) {
                _onChange(rval);
              },
            ),
            new Text("足球"),
            new Radio(
              value: 2,
              groupValue: rvalue,
              onChanged: (int rval) {
                _onChange(rval);
              },
            ),
            new Text("篮球"),
            new Radio(
              value: 3,
              groupValue: rvalue,
              onChanged: (int rval) {
                _onChange(rval);
              },
            ),
            new Text("排球"),
          ],
        ),
      ),
    );
  }
}

class _DDRadioGroupTestState2 extends State<DDRadioGroupTest> {
  static DDRadioItemValue<int> yes = DDRadioItemValue<int>(text: "是", value: 1);
  static DDRadioItemValue<int> no = DDRadioItemValue<int>(text: "否", value: 0);
  List<DDRadioItemValue<int>> items = <DDRadioItemValue<int>>[yes, no];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('text'),
      ),
      body: Container(
        padding: EdgeInsets.all(32.0),
        child: Column(
          children: <Widget>[
            DDRadioGroup(no, items),
          ],
        ),
      ),
    );
  }
}
